package com.own.component.common.mvc.intercept;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.validation.constraints.NotNull;

/**
 * TraceIdInterceptor
 *
 * @author chenxueli
 * @date 2022-08-30 14:04:00
 */
@SpringBootConfiguration
public class TraceIdInterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(@NotNull InterceptorRegistry registry) {
        // 注册TraceIdInterceptor拦截器
        var registration = registry.addInterceptor(new TraceIdInterceptor());
        // 所有路径都被拦截
        registration.addPathPatterns("/**");
    }

}
